package CACA;

import java.util.ArrayList;

public class ORTreeNode{

	boolean isLeaf = false;
	int index = -1;
	Item item;
	RuleInfo ruleInfor;
	ORTreeNode fatherNode;
	ArrayList<ORTreeNode> childNodes = new ArrayList<ORTreeNode>();

	public ORTreeNode(ORTreeNode father, Item it) {
		fatherNode = father;
		item = it;
	}
	public ORTreeNode() {
		
	}
	public boolean isLeaf()
	{
		return isLeaf;
	}
	

	public boolean isSubItemSet(ORTreeNode node2)
	{
		ORTreeNode node1 = this;
		int n = node2.ruleInfor.nItem - node1.ruleInfor.nItem;
			
		while(n>=0 && node1.item != null && node2.item != null)
		{
			if(node1.item .isEqual(node2.item ))
			{
				node1 = node1.fatherNode;
			}
			else
			{
				n--;
			}
			node2 = node2.fatherNode;
		}
		
		return node1.item == null;
	}

	public void setRuleInfo(Rule rule) {
		ruleInfor = new RuleInfo(rule);
		isLeaf = true;
	}
	public RuleInfo getRuleInfor() {
		return ruleInfor;
	}
	public ArrayList<ORTreeNode> getChildNodes() {
		return childNodes;
	}

	public Item getItem() {
		// TODO Auto-generated method stub
		return item;
	}
	public ORTreeNode getFatherNode() {
		// TODO Auto-generated method stub
		return fatherNode;
	}
	

}
